﻿using Microsoft.FxCop.Sdk;

namespace Lephone.FxCop.Rules
{
    internal static class CommonFunctions
    {
        public static SrcContext GetSrcContext(Method method)
        {
            var result = new SrcContext(method.SourceContext);
            int StartLine = 0x7fffffff, EndLine = 0;
            foreach (var item in method.Instructions)
            {
                if (item.SourceContext.StartLine < StartLine)
                {
                    StartLine = item.SourceContext.StartLine;
                }
                if (item.SourceContext.EndLine > EndLine)
                {
                    EndLine = item.SourceContext.EndLine;
                }
            }
            result.EndLine = EndLine;
            return result;
        }
    }
}
